package com.qfedu.lc.user.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.qfedu.lc.user.entity.VipOrder;
import com.qfedu.lc.user.mapper.VipOrderMapper;
import com.qfedu.lc.user.service.VipOrderService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 9.用户vip订单表 服务实现类
 * </p>
 *
 * @author wgz
 * @since 2024-01-29
 */
@Service
public class VipOrderServiceImpl extends ServiceImpl<VipOrderMapper, VipOrder> implements VipOrderService {

    @Autowired
    private VipOrderMapper vipOrderMapper;

    @Override
    public boolean updateVipOrderState(String no, int state) {
        QueryWrapper<VipOrder> vipOrderQueryWrapper = new QueryWrapper<>();

        vipOrderQueryWrapper.eq("no",no);
        VipOrder vipOrder = vipOrderMapper.selectOne(vipOrderQueryWrapper);

        if (vipOrder==null){
            return false;
        }

        vipOrder.setStatus(state);
        int num = vipOrderMapper.updateById(vipOrder);
        if (num>0){
            return true;
        }

        return false;
    }
}
